package com.yowasa.xiuxian.engine.battle.strategy.skill.water;

import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name="摧心浪")
@Order(1003)
@Component
public class CuiXinLang extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;
    @Override
    public ElementEnum getElement() {
        return ElementEnum.WATER;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int atk = first.getBattleInfo().getSpell();
        int def = second.getBattleInfo().getRes();
        int dmg = battleHelper.calSpell(atk, def)  * (10 + 2*first.getTurn()) / 10;;
        battleHelper.autoAction(this, first, second, content, dmg, "摧心浪");
    }

    @Override
    public void limit(UserBO user) {
        if (user.getElement().get("水") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY) {
            throw new HandlerException("学习/使用摧心浪必须具有水灵根");
        }
    }
    @Override
    public String limitDesc() {
        return "具有水灵根";
    }

    @Override
    public String desc() {
        return "摧心浪额外提升回合数*20%的术法攻击力";
    }
}
